#include "informationdialog.h"

#include <qt4/QtUiTools/QUiLoader>
#include <qt4/QtCore/QFile>
#include <qt4/QtGui/QDialogButtonBox>
#include <qt4/QtGui/QLabel>

QDialog* message_dialog = 0;
QDialogButtonBox* about_close_button = 0;
QLabel* message_label = 0;

InformationDialog::InformationDialog()
{
    QUiLoader ui_loader;
    QFile ui_file("dialog.ui");
    QWidget *ui_widget = ui_loader.load(&ui_file);

    message_dialog = dynamic_cast<QDialog*>(ui_widget);
    about_close_button = message_dialog->findChild<QDialogButtonBox*>("buttonBox");
    connect(about_close_button, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close(std::string&)));

    message_label = message_dialog->findChild<QLabel*>("labelStatus");
}

void InformationDialog::show(const std::string& message)
{
    message_label->setText(QString::fromUtf8(message.c_str()));
    message_dialog->exec();
}

void InformationDialog::close()
{
    message_dialog->close();
}
